import 'package:flutter/material.dart';

import 'CartPage.dart';
import 'CategoryPage.dart';
import 'HomePage.dart';

class Tabs extends StatefulWidget {
  @override
  _TabsState createState() => _TabsState();
}

class _TabsState extends State<Tabs> {
  int _currendIndex = 0;

  //初始化首页三个页面
  List _pageList = [HomePage(), CategoryPage(), CartPage()];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("我的小店"),
      ),
      body: this._pageList[_currendIndex],
      bottomNavigationBar: BottomNavigationBar(
        items: [
          BottomNavigationBarItem(icon: Icon(Icons.home), title: Text("首页")),
          BottomNavigationBarItem(
              icon: Icon(Icons.category), title: Text("分类")),
          BottomNavigationBarItem(
              icon: Icon(Icons.shopping_cart), title: Text("购物车")),
        ],
        currentIndex: _currendIndex,
        onTap: (index) {
          setState(() {
            _currendIndex = index;
          });
        },
        iconSize: 36,
        type: BottomNavigationBarType.fixed,
      ),
    );
  }
}
